<!DOCTYPE html>
<html>
    <head>
        <meta charset="UTF-8">
        <title>注册</title>
        <link rel="stylesheet" href="__PUBLIC__/layui/css/layui.css">
        <link rel="stylesheet" href="__CSS__/tplay.css">
    </head>
    <body>
    	<div class="tplay-login-body">
	        <form class="layui-form" id="tplay-login">
			  <div class="layui-form-item">
			      <input type="text" name="username" lay-verify="required" placeholder="账户" autocomplete="off" class="layui-input">
			  </div>
			  <div class="layui-form-item">
			      <input type="password" name="password" lay-verify="required" placeholder="密码" autocomplete="off" class="layui-input">
			  </div>
              <div class="layui-form-item">
                  <input type="password" required name="password_confirm" placeholder="确认密码" autocomplete="off" class="layui-input">
              </div>
              <div class="layui-form-item">
                  <input type="text" required name="name" placeholder="昵称" autocomplete="off" class="layui-input">
              </div>
			  <div class="layui-form-item">
			      <div class="layui-input-inline">
			        <input type="text" name="captcha" placeholder="验证码" autocomplete="off" class="layui-input">
			      </div>
			      <div class="layui-input-inline">
			        <img src="/captcha" class="layadmin-user-login-codeimg" height="39" width="200" onclick="this.src='/captcha?seed='+Math.random()" id="captcha">
			      </div>
			  </div>
			  <button class="layui-btn layui-btn-fluid" lay-submit lay-filter="tplay-login-submit" id="tplay-login-submit">注册</button>
			</form>
			<a href="{:url('index/user/login')}" class="tplay-login-a">已经拥有了账号？</a><a href="{:url('index/user/qqLogin')}" class="tplay-login-a">QQ授权登录</a>
		</div>
		<script src="__PUBLIC__/layui/layui.js"></script>
		<script type="text/javascript">
		    layui.use(['form'], function () {
		        var form = layui.form,$ = layui.$,apiconfig = layui.apiconfig;
		        form.on('submit(tplay-login-submit)', function(data) {
                    $.ajax({
                        url:"/index/user/registered",
                        data:$('#tplay-login').serialize(),
                        type:'post',
                        async: false,
                        success:function(res) {
                            layer.tips(res.msg,'#tplay-login-submit');
                            if(res.code == 1) {
                                setTimeout(function() {
                                    location.href = res.url;
                                }, 1000);
                            } else {
                                $('#captcha').click();
                            }
                        }
                    })
                    return false;
                });
		    });
		</script>
    </body>
</html>